import dbConnect from 'configs/dbConnect' import withSession from 'hocs/withSession' import Note from 'models/Note' export default withSession(async (req, res) => { const {id} = req.query await dbConnect() switch (req.method) { case 'GET': try { const user = req.session.get('user') if (!user || !user?.isVerified || !id ) { throw new Error('Something went wrong') } const note = await Note.getNote(id) if (!note) { throw new Error('Something went wrong') } res.status(200).json(note) } catch (error) { console.log(error) res.status(400).json({error: true}) } break } })